home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
HAM Radio 1997
/
HAM Radio 1997.iso
/
vcls
/
moden
/
admodem.int
< prev
next >
Wrap
Text File
|
1996-04-08
|
17KB
|
455 lines
{$G+,X+,F+}
{Conditional defines that may affect this unit}
{$I AWDEFINE.INC}
{*********************************************************}
{* ADMODEM.PAS 1.01 *}
{* Copyright (c) TurboPower Software 1995 *}
{* All rights reserved. *}
{*********************************************************}
unit AdModem;
{-Delphi modem component}
interface
uses
WinProcs,
{-----RTL}
SysUtils,
Classes,
Messages,
WinTypes,
DsgnIntf,
Forms,
Controls,
{-----APD}
OoMisc,
{$IFNDEF UseAPWDLL}
AwModem,
{$ENDIF}
AdMisc,
AdExcept,
AdPort,
AdModDB;
{$IFDEF UseAPWDLL}
{$I AWMODEM.PA0}
{$ENDIF}
const
{defaults}
DefAutoStart = True;
type
{!!.01 - added}
TModemStatus = (msModemOK, msModemConnect, msModemBusy, msModemVoice,
msModemNoCarrier, msModemNoDialTone, msModemError,
msGotLineSpeed, msGotErrCorrection, msGotDataCompression,
msCmdTimeout, msDialTimeout, msAnswerTimeout, msDialCount,
msAnswerCount, msModemRing, msModemIsConnected, msConnectFailed);
TLineSpeedEvent = procedure(M : TObject; Speed : LongInt) of object;
TConnectCountEvent = procedure(M : TObject; Remaining : Word) of object;
{!!.01 - added}
TModemEvent = procedure(M : TObject; WhatHappened : TModemStatus; Data : LongInt) of object;
{.Z+}
PPChar = ^PChar;
TTagSet = class(TPersistent)
protected {private}
FStrings : array[1..MaxTags] of TTagString;
function GetStr(Index : Integer) : TTagString;
procedure SetStr(Index : Integer; const Tag : TTagString);
public
constructor Create;
property Strings[Index : Integer] : TTagString
read GetStr write SetStr;
published
property String1 : TTagString
read FStrings[1] write FStrings[1];
property String2 : TTagString
read FStrings[2] write FStrings[2];
property String3 : TTagString
read FStrings[3] write FStrings[3];
property String4 : TTagString
read FStrings[4] write FStrings[4];
property String5 : TTagString
read FStrings[5] write FStrings[5];
end;
{.Z-}
TApdCustomModem = class(TComponent)
protected {private}
{.Z+}
ModemRec : PModemRec; {record passed to API calls}
FComPort : TApdCustomComPort; {port modem is attached to}
Data : TModemInfo; {data about modem}
FDialTimeout : Word;
FAnswerTimeout : Word;
FDelayFactor : Word;
FCmdTimeout : Word;
FDTRDropHold : Word;
FCharDelay : Word;
FTildeDelay : Word;
FRingWaitTimeout : Word;
FAutoStart : Boolean;
FStarted : Boolean;
FDataCompressionTags : TTagSet;
FErrorCorrectionTags : TTagSet;
FModemOk : TNotifyEvent;
FModemConnect : TNotifyEvent;
FModemBusy : TNotifyEvent;
FModemVoice : TNotifyEvent;
FModemNoCarrier : TNotifyEvent;
FModemNoDialTone : TNotifyEvent;
FModemError : TNotifyEvent;
FGotLineSpeed : TLineSpeedEvent;
FGotErrCorrection : TNotifyEvent;
FGotDataCompression : TNotifyEvent;
FCmdTimedOut : TNotifyEvent;
FDialTimedOut : TNotifyEvent;
FAnswerTimedOut : TNotifyEvent;
FDialCount : TConnectCountEvent;
FAnswerCount : TConnectCountEvent;
FOnByeBye : TNotifyEvent;
FModemIsConnected : TNotifyEvent; {!!.01}
FConnectFailed : TNotifyEvent; {!!.01}
FCommandProcessed : TModemEvent; {!!.01}
FModemRing : TNotifyEvent; {!!.01}
FModemEvent : TModemEvent; {!!.01}
procedure SetComPort(const NewPort : TApdCustomComPort);
{-Change the modem's com port}
procedure SetModemStrPrim(const NewData : String; var Data : String; RecData : PPChar);
{-Set a modem's string field}
procedure SetInitCmd(Cmd : TCmdString);
{-Set the modem's InitCmd field}
procedure SetDialCmd(Cmd : TCmdString);
{-Set the modem's DialCmd field}
procedure SetDialTerm(Cmd : TCmdString);
{-Set the modem's DialTerm field}
procedure SetDialCancel(Cmd : TCmdString);
{-Set the modem's DialCancel field}
procedure SetHangupCmd(Cmd : TCmdString);
{-Set the modem's HangupCmd field}
procedure SetConfigCmd(Cmd : TConfigString);
{-Set the modem's ConfigCmd field}
procedure SetAnswerCmd(Cmd : TCmdString);
{-Set the modem's AnswerCmd field}
procedure SetOkMsg(Rsp : TRspString);
{-Set the modem's OkMsg field}
procedure SetConnectMsg(Rsp : TRspString);
{-Set the modem's ConnectMsg field}
procedure SetBusyMsg(Rsp : TRspString);
{-Set the modem's BusyMsg field}
procedure SetVoiceMsg(Rsp : TRspString);
{-Set the modem's VoiceMsg field}
procedure SetNoCarrierMsg(Rsp : TRspString);
{-Set the modem's NoCarrierMsg field}
procedure SetNoDialToneMsg(Rsp : TRspString);
{-Set the modem's NoDialToneMsg field}
procedure SetErrorMsg(Rsp : TRspString);
{-Set the modem's ErrorMsg field}
procedure SetRingMsg(Rsp : TRspString);
{-Set the modem's RingMsg field}
procedure SetDataCompressionTags(const Tags : TTagSet);
{-Set modem data compression tags}
procedure SetErrorCorrectionTags(const Tags : TTagSet);
{-Set modem error correction tags}
procedure SetLockDTE(Lock : Boolean);
{-Set whether the modem should lock the port rate or not}
procedure SetDialTimeout(Secs : Word);
{-Set the number of seconds before a dial attempt times out}
procedure SetAnswerTimeout(Secs : Word);
{-Set the number of seconds before an answer attempt times out}
procedure SetDelayFactor(Ticks : Word);
{-Set the number of ticks to wait between commands sent to the modem}
procedure SetCmdTimeout(Ticks : Word);
{-Set the number of ticks to wait for a modem response}
procedure SetDTRDropHold(Ticks : Word);
{-Set the number of ticks to hold DTR low during hangup}
procedure SetCharDelay(Ticks : Word);
{-Set the number of ticks to wait between each command character sent}
procedure SetTildeDelay(Ticks : Word);
{-Set the number of ticks to wait when a '~' is encountered in a command}
procedure SetRingWaitTimeout(Ticks : Word);
{-Set the number of ticks to wait before AutoAnswer resets}
procedure SetStarted(Start : Boolean);
{-Start or stop the modem}
procedure SetModemInfo(const Info : TModemInfo);
{-Set all fields for a modem}
procedure Notification(AComponent : TComponent; Operation : TOperation); override;
procedure CreateModemRecord;
{-Create the record passed to the API functions}
procedure DestroyModemRecord;
{-Destroy the record passed to the API functions}
procedure AssureStarted;
{-Make sure the modem has been started}
procedure ModemPortClose(CP : TObject; Opening : Boolean); {!!.01}
{-Called when the port the modem is attached to is closed} {!!.01}
protected
{event methods}
procedure ModemOk; virtual;
procedure ModemConnect; virtual;
procedure ModemBusy; virtual;
procedure ModemVoice; virtual;
procedure ModemNoCarrier; virtual;
procedure ModemNoDialTone; virtual;
procedure ModemError; virtual;
procedure GotLineSpeed(Speed : LongInt); virtual;
procedure GotErrCorrection; virtual;
procedure GotDataCompression; virtual;
procedure CmdTimedOut; virtual;
procedure DialTimedOut; virtual;
procedure AnswerTimedOut; virtual;
procedure DialCount(Remaining : Word); virtual;
procedure AnswerCount(Remaining : Word); virtual;
procedure ModemIsConnected; virtual; {!!.01}
procedure ConnectFailed; virtual; {!!.01}
procedure ModemRing; virtual; {!!.01}
{!!.01 - added}
procedure CommandProcessed(const WhatHappened : TModemStatus); virtual;
{!!.01 - added}
procedure ModemEvent(const WhatHappened : TModemStatus; const Data : LongInt);
public
{creation/destruction}
constructor Create(AOwner : TComponent); override;
destructor Destroy; override;
{.Z-}
property Started : Boolean
read FStarted write SetStarted;
property ModemInfo : TModemInfo
read Data write SetModemInfo;
{com port this is linked to}
property ComPort : TApdCustomComPort
read FComPort write SetComPort;
{set this property TRUE to set Start := True automatically}
property AutoStart : Boolean
read FAutoStart write FAutoStart default DefAutoStart;
{commands, timeouts, etc.}
property InitCmd : TCmdString
read Data.InitCmd write SetInitCmd;
property DialCmd : TCmdString
read Data.DialCmd write SetDialCmd;
property DialTerm : TCmdString
read Data.DialTerm write SetDialTerm;
property DialCancel : TCmdString
read Data.DialCancel write SetDialCancel;
property HangupCmd : TCmdString
read Data.HangupCmd write SetHangupCmd;
property ConfigCmd : TConfigString
read Data.ConfigCmd write SetConfigCmd;
property AnswerCmd : TCmdString
read Data.AnswerCmd write SetAnswerCmd;
property OkMsg : TRspString
read Data.OkMsg write SetOkMsg;
property ConnectMsg : TRspString
read Data.ConnectMsg write SetConnectMsg;
property BusyMsg : TRspString
read Data.BusyMsg write SetBusyMsg;
property VoiceMsg : TRspString
read Data.VoiceMsg write SetVoiceMsg;
property NoCarrierMsg : TRspString
read Data.NoCarrierMsg write SetNoCarrierMsg;
property NoDialToneMsg : TRspString
read Data.NoDialToneMsg write SetNoDialToneMsg;
property ErrorMsg : TRspString
read Data.ErrorMsg write SetErrorMsg;
property RingMsg : TRspString
read Data.RingMsg write SetRingMsg;
property DataCompressionTags : TTagSet
read FDataCompressionTags write SetDataCompressionTags;
property ErrorCorrectionTags : TTagSet
read FErrorCorrectionTags write SetErrorCorrectionTags;
property LockDTE : Boolean
read Data.LockDTE write SetLockDTE;
property DialTimeout : Word
read FDialTimeout write SetDialTimeout default DefDialTimeout;
property AnswerTimeout : Word
read FAnswerTimeout write SetAnswerTimeout default DefAnswerTimeout;
property DelayFactor : Word
read FDelayFactor write SetDelayFactor default DefDelayFactor;
property CmdTimeout : Word
read FCmdTimeout write SetCmdTimeout default DefCmdTimeout;
property DTRDropHold : Word
read FDTRDropHold write SetDTRDropHold default DefDTRDropHold;
property CharDelay : Word
read FCharDelay write SetCharDelay default DefModemCharDelay;
property TildeDelay : Word
read FTildeDelay write SetTildeDelay default DefTildeDelay;
property RingWaitTimeout : Word
read FRingWaitTimeout write SetRingWaitTimeout default DefRingWaitTimeout;
{events}
property OnModemOk : TNotifyEvent
read FModemOk write FModemOk;
property OnModemConnect : TNotifyEvent
read FModemConnect write FModemConnect;
property OnModemBusy : TNotifyEvent
read FModemBusy write FModemBusy;
property OnModemVoice : TNotifyEvent
read FModemVoice write FModemVoice;
property OnModemNoCarrier : TNotifyEvent
read FModemNoCarrier write FModemNoCarrier;
property OnModemNoDialTone : TNotifyEvent
read FModemNoDialTone write FModemNoDialTone;
property OnModemError : TNotifyEvent
read FModemError write FModemError;
property OnGotLineSpeed : TLineSpeedEvent
read FGotLineSpeed write FGotLineSpeed;
property OnGotErrCorrection : TNotifyEvent
read FGotErrCorrection write FGotErrCorrection;
property OnGotDataCompression : TNotifyEvent
read FGotDataCompression write FGotDataCompression;
property OnCmdTimedOut : TNotifyEvent
read FCmdTimedOut write FCmdTimedOut;
property OnDialTimedOut : TNotifyEvent
read FDialTimedOut write FDialTimedOut;
property OnAnswerTimedOut : TNotifyEvent
read FAnswerTimedOut write FAnswerTimedOut;
property OnDialCount : TConnectCountEvent
read FDialCount write FDialCount;
property OnAnswerCount : TConnectCountEvent
read FAnswerCount write FAnswerCount;
property OnByeBye : TNotifyEvent
read FOnByeBye write FOnByeBye;
property OnCommandProcessed : TModemEvent {!!.01}
read FCommandProcessed write FCommandProcessed; {!!.01}
property OnModemIsConnected : TNotifyEvent {!!.01}
read FModemIsConnected write FModemIsConnected; {!!.01}
property OnConnectFailed : TNotifyEvent {!!.01}
read FConnectFailed write FConnectFailed; {!!.01}
property OnModemRing : TNotifyEvent {!!.01}
read FModemRing write FModemRing; {!!.01}
property OnModemEvent : TModemEvent {!!.01}
read FModemEvent write FModemEvent; {!!.01}
procedure PutCommand(const Cmd : String);
{-Put a command to the modem and handle the response}
procedure Initialize;
{-Send the initialization string to the modem}
procedure Configure;
{-Send the configuration strings to the modem}
procedure Dial(const Number : String);
{-Dial the modem}
function IsAttemptingConnect : Boolean;
{-Return TRUE if the modem is attempting to establish a connection}
procedure ExtendConnectAttempt(const DeltaSecs : Integer);
{-Extend the amount of time the modem waits for a CONNECT result}
procedure CancelDialAnswer;
{-Cancel the dial/answer in progress}
function GetConnectSpeed : LongInt;
{-Get the actual speed of the connection}
procedure Hangup;
{-Hangup the modem}
procedure Answer;
{-Answer the modem}
procedure AutoAnswer(const Rings : Word);
{-Answer the modem after Rings rings}
function FeatureWaitOver : Boolean;
{-Return TRUE if all modem features have been received and processed}
procedure WaitOnFeatures;
{-Wait until all modem features have been received}
procedure WaitOnResponse;
{-Wait until the modem finishes processing the last command}
end;
TApdModem = class(TApdCustomModem)
published
{com port this is linked to}
property ComPort;
{commands, timeouts, etc.}
property InitCmd;
property DialCmd;
property DialTerm;
property DialCancel;
property HangupCmd;
property ConfigCmd;
property AnswerCmd;
property OkMsg;
property ConnectMsg;
property BusyMsg;
property VoiceMsg;
property NoCarrierMsg;
property NoDialToneMsg;
property ErrorMsg;
property RingMsg;
property DataCompressionTags;
property ErrorCorrectionTags;
property LockDTE;
property DialTimeout;
property AnswerTimeout;
property DelayFactor;
property CmdTimeout;
property DTRDropHold;
property CharDelay;
property TildeDelay;
property RingWaitTimeout;
{events}
property OnModemOk;
property OnModemConnect;
property OnModemBusy;
property OnModemVoice;
property OnModemNoCarrier;
property OnModemNoDialTone;
property OnModemError;
property OnGotLineSpeed;
property OnGotErrCorrection;
property OnGotDataCompression;
property OnCmdTimedOut;
property OnDialTimedOut;
property OnAnswerTimedOut;
property OnDialCount;
property OnAnswerCount;
property OnCommandProcessed; {!!.01}
property OnModemIsConnected; {!!.01}
property OnConnectFailed; {!!.01}
property OnModemRing; {!!.01}
property OnModemEvent; {!!.01}
end;
const
DefModemData : TModemInfo =
( Name : '';
InitCmd : 'ATZ^M';
DialCmd : 'ATDT';
DialTerm : '^M';
DialCancel : '^M';
HangupCmd : '+++~~~ATH0^M';
ConfigCmd : 'ATE1Q0X1V1^M';
AnswerCmd : 'ATA^M';
OkMsg : 'OK';
ConnectMsg : 'CONNECT';
BusyMsg : 'BUSY';
VoiceMsg : 'VOICE';
NoCarrierMsg : 'NO CARRIER';
NoDialToneMsg : 'NO DIALTONE';
ErrorMsg : 'ERROR';
RingMsg : 'RING';
NumErrors : 0;
Errors : ('', '', '', '', '');
NumComps : 0;
Compression : ('', '', '', '', '');
LockDTE : True;
DefBaud : 19200
);